package mapper;

import com.wmz.javabean.User;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;


import java.util.List;

public interface UserMapper {
    @Select({"select * from user"})
    List<User> selectAll();
    //根据user对象数据进行查询
    //对应的数据如果不是默认值就查询对应数据
    @Select("<script>" +
            "select * from user where 1=1" +
            "<if test='uid != null and uid != 0'> and uid=#{uid}</if>" +
            "<if test='username != null'> and username=#{username}</if>" +
            "<if test='phone != null'> and phone=#{phone}</if>" +
            "</script>")
    List<User> selectByUser(User user);

    @Delete("<script>" +
            "delete from user where uid in " +
            "<foreach collection='array' item='uid' separator=',' open='(' close=')'>" +
            "#{uid}" +
            "</foreach>" +
            "</script>")
    int deleteByArray(int[] ids);
}


